<!DOCTYPE html>
<html class="x-admin-sm">
<!-- 导购员审核页面 -->

<head>
    <meta charset="UTF-8">
    <title>保购审核页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link href="css/newStyle.css" rel="stylesheet">
    <!-- 弹窗轻提示 -->
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="js/plugins/sweetalert/sweetalert.min.js"></script>
    <!-- 引入jq -->
    <script src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="./js/common.js"></script>
    <!-- <script type="text/javascript" src="./js/domain.js"></script> -->

    <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    <style>
        .fl {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        /* 筛选模块 */

        .searchPart {
            border: 1px solid #ccc;
            margin: 15px 15px 5px 15px;
            background-color: #fff;
        }

        .layui-form-item {
            margin-bottom: 3px;
        }

        /* 表格部分 */

        .FormTablePart,
        .TotalTablePart,
        .FanTablePart {
            margin: 15px 15px;
        }

        .FormTablePart {
            border: 1px solid #ddd;
            height: 33vh;
            text-align: center;
        }

        .userImg .layui-icon {
            font-size: 70px;
            color: #ccc;
        }

        .userNum {
            font-size: 16px;
            margin: 15px 0;
        }

        .userText {
            width: 100px;
            height: 25px;
            line-height: 25px;
            /* background: #f04844; */
            border-radius: 10px;
            margin: 0 auto;
            color: #fff;
        }

        .FormTablePartLf {
            padding-top: 20px;
            flex: 2.1;
        }

        .FormTablePartLf1 {
            padding-top: 20px;
            flex: 3;
        }

        .FormTablePartRg {
            flex: 7.9;
            height: 100%;
            margin-top: 20px;
        }

        .layui-table-view .layui-table {
            width: 100%;
            height: 100%;
        }


        .totalTitle,
        .fanTitle {
            font-size: 16px;
            color: #666;
        }

        .sfz_photo {
            display: flex;
            align-items: center;
            justify-content: space-around !important;
        }

        .sfz {
            width: 300px;
            height: 180px;
            background-color: #000;
            margin: 45px 0px;
            float: left;
            overflow: hidden;
        }

        .sfz img {
            width: 100%;
            height: 100%;
            display: block;
        }

        .FormTablePart {
            height: 200px;
        }

        .layui-form-label {
            width: 120px !important;
        }

        .layui-input {
            width: 200px !important;
            text-align: center;
            height: 20px;
            line-height: 32px;
        }

        .userText {
            display: flex;
            justify-content: space-between;
            /* background-color: #fff; */
        }

        .userText div {
            width: 280px;
            height: 180px;
        }

        .FormTablePartLf .sfz img {
            width: 100%;
            height: 100%;
        }

        .user_star {
            text-align: center;
            height: 30px;
            line-height: 30px;
            color: #fff;
            background-color: #f04844;
            width: 80px;
            border-radius: 15px;
            margin-left: 115px;
            margin-top: 5px;
        }

        .user_photo {
            font-size: 15px;
        }

        .layui-laypage {
            margin-left: 346px !important;
        }

        .sum_btn {
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .sum_btn .layui-btn {
            height: 36px !important;
            width: 160px !important;
        }

        .noPass_ber {
            background-color: #fff !important;
            margin-right: 20px !important;
            color: #000 !important;
            border: 1px solid #000;
        }

        .layui-laypage-skip>.layui-input {
            width: 50px !important;
        }

        .goods_name {
            display: inline-block;
            width: 100px;
            height: 30px;
            line-height: 30px;
            background-color: #1abc9c;
            text-align: center;
        }

        .layui-table td,
        .layui-table th {
            max-width: 150px !important;
            text-align: center !important;
        }

        .none {
            display: none;
        }

        .pass_ber {
            font-size: 13px !important;
            width: 180px !important;
            height: 35px !important;
            border-radius: 4px !important;
            background-color: rgba(26, 188, 156, 1) !important;
            color: #fff !important;
            margin: 40px auto;
        }

        .noPass_ber {
            font-size: 13px !important;
            width: 180px !important;
            height: 35px !important;
            border-radius: 4px !important;
            background-color: rgba(255, 255, 255, 1) !important;
            color: #000 !important;
            /* margin: 40px auto; */
        }

        .star_fan table tbody tr {
            background-color: #eaf5fc;
        }

        .star_fan table tbody tr:hover {
            background-color: #d4e6f0;
        }

        table thead tr {
            background-color: #f2f2f2 !important;
        }
    </style>
</head>

<body>

    <!-- 导航条模块 -->
    <div class="x-nav" style="padding-top: 5px;  position: fixed; top: 0;width: 100%;">
        <a style="display: inline-block; " class="layui-btn layui-btn-small">
            <cite>保购审核</cite>
        </a>
        <a class="layui-btn " style="line-height:1.6em;margin-top:3px;float:right; position: relative; left: -30px;"
            onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px">刷新</i>
        </a>

    </div>

    <!-- 导购员信息模块 -->
    <div class="FormTablePart fl" style="margin-top: 60px;">
        <div class="FormTablePartLf1">
            <div class="userImg">
                <!-- <i class="layui-icon layui-icon-username" style="line-height:30px"></i> -->
                <img src="#" alt="" class="user_img" style="width: 120; height: 120px; border-radius: 60px; ">
            </div>
            <div class="userNum" style="position: relative; bottom: 4px;"></div>
            <div class="user_star" style="position: relative;bottom: 16px;"></div>

        </div>
        <div class="FormTablePartRg">
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item fl" style="margin-top: 20px;">
                    <div class="layui-inline">
                        <label class="layui-form-label">保购账号</label>
                        <div class="layui-input-inline">
                            <p class="layui-input manNum"> </p>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-inline">
                            <p class="layui-input userPhone"></p>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item fl">
                    <div class="layui-inline">
                        <label class="layui-form-label">真实姓名</label>
                        <div class="layui-input-inline">
                            <p class="layui-input salesName"></p>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">昵称</label>
                        <div class="layui-input-inline">
                            <p class="layui-input userName"></p>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item fl">

                    <div class="layui-inline">
                        <label class="layui-form-label">身份证号码</label>
                        <div class="layui-input-inline">
                            <p class="layui-input card_number"></p>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">会员注册</label>
                        <div class="layui-input-inline">
                            <p class="layui-input  user_create_time "></p>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item fl">
                    <div class="layui-inline">
                        <label class="layui-form-label">提交审核</label>
                        <div class="layui-input-inline">
                            <p class="layui-input create_time "></p>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">来源</label>
                        <div class="layui-input-inline">
                            <p class="layui-input origin"></p>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="FormTablePart fl">
        <div class="FormTablePartLf">
            <p class="user_photo">身份证照片</p>
        </div>
        <div style="height: 100%;width: 1px;overflow: hidden;background-color: #ddd;"></div>

        <div class="FormTablePartRg userText sfz_photo" style="margin-top: -5px; width: 80px;">
            <!-- 身份证图片 -->
            <div class="sfz"><img src="#" alt="正在加载" class="photo_up" onclick="previewImg(this)"> </div>
            <div class="sfz"><img src="#" alt="正在加载" class="photo_back" onclick="previewImg(this)"> </div>
        </div>
    </div>

    <div style="margin:0 15px;">
        <table class="layui-hide" id="test"></table>
    </div>
    <div class="layui-form-item sum_btn" style="margin:60px;">
        <button class="layui-btn  noPass_ber" style="padding: 0 30px;margin-right: 20px;">拒绝</button>

        <button class="layui-btn pass_ber" style="padding: 0 30px;margin-right: 20px;">通过</button>
    </div>
    <script>
        layui.use('table', function () {
            var table = layui.table;

            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null) return unescape(r[2]); return null; //返回参数值
            }
            var buyMid = getUrlParam("id"); //当前导购员id
            //   console.log(buyMid,'导购员id')
            Showload();
            $.ajax({
                type: 'post',
                url: urls + 'sales/getSalesDetails',
                headers: {
                    'X-Access-Token': JSON.parse(sessionStorage.getItem("user_message")).token,
                },
                data: { id: buyMid, token: token },
                success: function (res) {
                    CheckLogout(res); //检查是否登陆过
                    if (res.code == 0) {
                        InitTime();
                        // console.log(res, '9696')
                        $('.user_img').attr('src', imgUrl + res.data.head_url)
                        $('.userNum').text(res.data.account_phone)
                        $('.user_star').text(res.data.sale)
                        $('.manNum').text(res.data.account_phone)
                        $('.userPhone').text(res.data.phone)
                        $('.salesName').text(res.data.salesName)
                        $('.userName').text(res.data.nickname)
                        $('.personal_signature').text(res.data.personal_signature)
                        if (res.data.sex == 1) {
                            $('.sex').text('男')
                        } else if (res.data.sex == 2) {
                            $('.sex').text('女')
                        } else {
                            $('.sex').text('保密')
                        }
                        $('.user_create_time').text(res.data.user_create_time)
                        $('.create_time').text(res.data.create_time)
                        $('.card_number').text(res.data.id_card_number)
                        $('.job_number').text(res.data.job_number)
                        $('.agency_number').text(res.data.agency_number)
                        $('.account').text(res.data.alipay_account)
                        $('.alipay_name').text(res.data.alipay_name)
                        // 销售类型
                        if (res.data.sale_type == 1) {
                            $('.sale_type').text('保购')
                        }
                        $('.origin').text(res.data.origin == 1 ? 'PC端' : 'APP端')
                        // 身份证渲染
                        $('.photo_up').attr('src', imgUrl + res.data.idCard1)
                        $('.photo_back').attr('src', imgUrl + res.data.idCard2)
                    } else {
                        TipsAlert("请求数据失败,请联系后台技术人员");
                    }
                }
            })
            //审核通过
            $('.pass_ber').on('click', function () {
                $.ajax({
                    type: 'post',
                    url: urls + 'sales/createExamine',
                    headers: {
                        'X-Access-Token': JSON.parse(sessionStorage.getItem("user_message")).token,
                    },
                    data: {
                        saleId: buyMid,
                        verifyResult: 1
                    },
                    success: function (res) {
                        CheckLogout(res); //检查是否登陆过
                        if (res.code == 0) {
                            layer.alert('该保购已审核通过,请返回！', {
                                icon: 6
                            });
                            $('.noPass_ber').css('display', 'none');
                            $('.pass_ber').css('display', 'none');
                        } else {
                            layer.alert(res.msg);
                        }
                    }
                })
            })
            //审核不通过
            $('.noPass_ber').on('click', function () {
                $.ajax({
                    type: 'post',
                    url: urls + 'sales/createExamine',
                    headers: {
                        'X-Access-Token': JSON.parse(sessionStorage.getItem("user_message")).token,
                    },
                    data: {
                        saleId: buyMid,
                        verifyResult: 2
                    },
                    success: function (res) {
                        CheckLogout(res); //检查是否登陆过
                        if (res.code == 0) {
                            layer.alert('该保购已审核不通过,请返回！', {
                                icon: 6
                            });
                            $('.noPass_ber').css('display', 'none');
                            $('.pass_ber').css('display', 'none');
                        } else {
                            layer.alert(res.msg);
                        }
                    }
                })
            })
            // 导购员申请记录
            table.render({
                elem: '#test'
                , url: urls + 'sales/statusSalesView'
                , headers: {
                    'X-Access-Token': JSON.parse(sessionStorage.getItem("user_message")).token,
                }
                , method: 'get'
                , where: { id: buyMid }
                // , page: true
                // , limits: ['5', '10', '20']
                // ,limit : 5
                , parseData: function (res) { //res 即为原始返回的数据
                    console.log(res, '申请记录')
                    CheckLogout(res); //检查是否登陆过
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.length, //解析数据长度
                        "data": res.data //解析数据列表
                    }
                }
                , cols: [[
                    , { field: 'verifyTimeString', title: '申请记录', align: 'center' }
                    , {
                        field: 'verifyResult', title: '审核状态', align: 'center',
                        templet: function (res) {
                            if (res.verifyResult == 1) {
                                return '审核通过'
                            } else if (res.verifyResult == 2) {
                                return '审核未通过'
                            }
                        }
                    }
                    , { field: 'verifyTime', title: '审核时间', align: 'center' }
                ]]
            });
        });
    </script>
    <script>
        function previewImg(obj) {
            var img = new Image();
            img.src = obj.src;
            //var height = img.height + 50; // 原图片大小
            //var width = img.width; //原图片大小
            var imgHtml = "<img src='" + obj.src + "' width='500px' height='500px'/>";
            //弹出层
            layer.open({
                type: 1,
                shade: 0.8,
                offset: 'auto',
                area: [500 + 'px', 550 + 'px'],  // area: [width + 'px',height+'px']  //原图显示
                shadeClose: true,
                scrollbar: false,
                title: "图片预览", //不显示标题  
                content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响  
                cancel: function () {
                    //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });  
                }
            });
        }

    </script>

</body>

</html>